learner_id=0;
proposer_id=3;   

cpu_folder="cpu/"
all_folder="all/"
lat_folder="lat/"
sd_avg_folder="sd_avg/"

delimeter="/"
txt_postfix=".txt"
pidstat="pidstat"$txt_postfix;
sirqpidstat="sirq-pidstat"$txt_postfix;
top="top"$txt_postfix;


config_file=$3;

general_path=$4;

interval=$5;
num_prop=$6;
folder_id=$7;
num_prop_different=$8;
num_proposers=$9
last=`expr $9 - 1`

 



for((i=$1; i<(($1+$2)); i++))
do
  echo $i; 
  
               pidstat_path=$general_path$folder_id$delimeter$cpu_folder$proposer_id$pidstat;
               sirq_pidstat=$general_path$folder_id$delimeter$cpu_folder$proposer_id$sirqpidstat;
                   top_path=$general_path$folder_id$delimeter$cpu_folder$proposer_id$top;
      performance_file_path=$general_path$folder_id$delimeter$all_folder$proposer_id$txt_postfix;
          latency_file_path=$general_path$folder_id$delimeter$lat_folder$proposer_id$txt_postfix;
           sd_avg_file_path=$general_path$folder_id$delimeter$sd_avg_folder$proposer_id$txt_postfix;
          
  echo $latency_file_path;
  
    ssh  -f -n  "node"${i} "pidstat 1 |grep learner  >> $pidstat_path";
    ssh  -f -n  "node"${i} "pidstat 1 |grep sirq-net-rx >> $sirq_pidstat";
    ssh -f -n "node"${i} "top -b -d 1 | grep learner >> $top_path";
	if((num_proposers>0))
		then
			send=1;
	else
		send=0;
	fi	
		
	if((learner_id==last))
		then
	 			ssh  -f -n "node"${i} "/home/parisa/PARISA-NICOLA/trunk/rpaxos-config-4/learner-proposer/learner-proposer $learner_id $proposer_id $config_file $interval $num_prop_different $performance_file_path $latency_file_path $sd_avg_file_path $send";
	    else
	 		    ssh  -f -n "node"${i} "/home/parisa/PARISA-NICOLA/trunk/rpaxos-config-4/learner-proposer/learner-proposer $learner_id $proposer_id $config_file $interval $num_prop $performance_file_path $latency_file_path $sd_avg_file_path $send";
 	fi		
			
  
  ((learner_id+=1));
  ((proposer_id+=1));
  ((num_proposers-=1));
  
done


